"""
__author__="yanwei"
__describe__="基类，包含网页公共元素和方法"
__API__="/keys/status/:id"
"""

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

class Base_Page:



    def find_element(self,locator):
        return self.wait.until(EC.visibility_of_element_located(locator))

    def find_elements(self,locator):
        return self.wait.until(EC.visibility_of_all_elements_located(locator))

    def search_element(self,driver,locator):
        """找到指定元素，超时时间为10秒"""
        wait = WebDriverWait(driver, 10)
        return wait.until(EC.presence_of_element_located((By.XPATH, locator)))

    def search_text(self,driver,locator,expected_text):
        """找到指定的文本，超时时间为10秒"""
        wait = WebDriverWait(driver,10)
        return wait.until(EC.text_to_be_present_in_element((By.XPATH, locator),expected_text))






